﻿using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
using System.Text.RegularExpressions;

public partial class Install : System.Web.UI.Page {
  protected void Page_Load(object sender, EventArgs e) {
    SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
    cnn.Open();
    string sql = File.ReadAllText(Server.MapPath("~/data.sql"));
    sql = sql.Replace("GO", "");

    //Optional to Replace Comments with empty string

    sql = Regex.Replace(sql, "([/*][*]).*([*][/])", "");

    //Optional to Replace Chain of spaces with one Space

    sql = Regex.Replace(sql, "\\s{2,}", " ");
    SqlCommand cmd = new SqlCommand(sql, cnn);
    cmd.ExecuteNonQuery();
    cnn.Close();
  }
}
